package tmall.secondkill.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tmall.framework.Response;
import tmall.secondkill.common.ErrorCodeEnum;
import tmall.secondkill.entity.Order;
import tmall.secondkill.mapper.OrderMapper;
import tmall.secondkill.service.OrderService;

/**
 * @author wei
 * @version 1.0.0
 * @description
 * @createTime 2022年01月23日 11:18:00
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    public Response order(Order order) {
        // TODO 此处交由线程池异步处理或发送到消息队列？
        // 校验时戳
        // 本地接口限流
        // redis 查库存并比较
        // 成功则发送至消息队列
        // 返回，提示用户支付
        return Response.of(ErrorCodeEnum.SUCCESS, order);
    }

    public Response orderStatus(long orderId) {
        Order order = orderMapper.selectById(orderId);
        return Response.of(ErrorCodeEnum.SUCCESS, order);
    }
}
